<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}


$page = !($_POST['pageNum'])?'1':intval($_POST['pageNum']);
$pagesize= !($_POST['numPerPage'])?'20':intval($_POST['numPerPage']);


if(empty($pagesize)){
    $pagesize=20;
}
$frmnum=($page-1)*$pagesize;
$orderField=trim($_POST["orderField"]);
$orderDirection=trim($_POST["orderDirection"]);
$jgid=$_REQUEST["jgid"];
if(empty($orderField)){
    $orderField="id";
}
if(empty($orderDirection)){
    $orderDirection="desc";
}
if($orderField<>""){
    $order=" order by $orderField ".$orderDirection;
}else{
    $order=" order by id desc";
}
$status=$_REQUEST["status"];
$q=trim($_POST['q']);
if($status=="1"){
    $where=' status=1';    
}elseif($status=="2"){
    $where=' status=2';    
}elseif($status=="0"){
    $where=' status=0';
}elseif($status=="3"){
    $where=' status=3';
}elseif($status=="4"){
    $where=' status=4';
}elseif($status=="5"){
    $where=' status=5';
}elseif($status=="-1"){
    $where=' status=-1';
}else{
    $where=' 1';
}

if($q<>""){
    
    $where.=" and ordersn like '%".$q."%'";
}
if(!empty($_SESSION['EZ_Admin']['shop_id'])&&$_SESSION['EZ_Admin']['shop_id']>0){
    $where.=" and shop_id=".$_SESSION['EZ_Admin']['shop_id']." and is_given=1";
}
if(!empty($jgid)){
    
    
    $where.=" and workid=".$jgid;
}
$total=$ezhand->count("shopping3_order",$where);
$row=$ezhand->select_all("shopping3_order",'*',''.$where.' '.$order.' limit '.$frmnum.','.$pagesize);
foreach($row as $key=>$val){
    $row[$key]['shop_name']=$ezhand->get_namebyid('shopping3_chef',"id=".$val['shop_id']."");
}
?>